//
//  EFPaySuccessViewController.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/18.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFPaySuccessViewController.h"

@interface EFPaySuccessViewController ()

@property(strong,nonatomic)UIImageView* qrCodeIV;
@property(strong,nonatomic)UILabel* tipsLabel;

@property(strong,nonatomic)UIButton* closeBtn;
@property(strong,nonatomic)UILabel* bottomTipsLabel;
@property (copy, nonatomic) NSString *qcodeUrl;
@end

@implementation EFPaySuccessViewController

- (instancetype)initWithQcodeUrl:(NSString *)qcodeUrl{
    self = [super init];
    if (self) {
        self.title = @"付款成功";
        self.qcodeUrl = qcodeUrl;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)initView{
    [self.view addSubview:self.qrCodeIV];
    [self.qrCodeIV setImageWithURL:[NSURL URLWithString:self.qcodeUrl]];
    [self.view addSubview:self.tipsLabel];
    [self.view addSubview:self.closeBtn];
    [self.view addSubview:self.bottomTipsLabel];
}

-(void)onClickClose{
    [self.navigationController popViewControllerAnimated:YES];
}


-(UIImageView *)qrCodeIV{
    if(_qrCodeIV == NULL){
        _qrCodeIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 134, 134)];
        _qrCodeIV.backgroundColor = kGrayColor;
       // [_qrCodeIV setImage:IMG(@"takeaway_button_default")];
        _qrCodeIV.left = (kScreenWidth - _qrCodeIV.width)/2;
        _qrCodeIV.top = 144;
    }
    return _qrCodeIV;
}


-(UILabel *)tipsLabel{
    if(_tipsLabel == NULL){
        _tipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 154, 38)];
        _tipsLabel.font = [UIFont systemFontOfSize:15];
        _tipsLabel.textColor = kBlack333;
        [_tipsLabel setText:@"离开超市请走快捷通道并出示此二维码"];
        _tipsLabel.numberOfLines = 0;
        _tipsLabel.left = (kScreenWidth - _tipsLabel.width)/2;
        _tipsLabel.top = self.qrCodeIV.bottom + 16;
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
        _tipsLabel.hidden = YES;
    }
    return _tipsLabel;
}


-(UIButton *)closeBtn{
    if(_closeBtn == NULL){
        _closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 35)];
        _closeBtn.top = self.bottomTipsLabel.top - 10 -   _closeBtn.height;
        _closeBtn.left = 20;
        _closeBtn.backgroundColor = RGBCOLOR(0x69BA45);
        _closeBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        _closeBtn.titleLabel.textColor = [UIColor whiteColor];
        [_closeBtn setTitle:@"关闭" forState:UIControlStateNormal];
        [_closeBtn addTarget:self action:@selector(onClickClose) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeBtn;
}


-(UILabel *)bottomTipsLabel{
    if(_bottomTipsLabel == NULL){
        _bottomTipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 154, 38)];
        _bottomTipsLabel.font = [UIFont systemFontOfSize:13];
        _bottomTipsLabel.textColor = kBlack999;
        [_bottomTipsLabel setText:@"如您提前关闭了此页面，在快速通道处扫码亦可显示"];
        [_bottomTipsLabel sizeToFit];
        _bottomTipsLabel.left = (kScreenWidth - _bottomTipsLabel.width)/2;
        _bottomTipsLabel.top = kScreenHeight - kStatusBarHeight  -_bottomTipsLabel.height - 30;
    }
    return _bottomTipsLabel;
}



@end
